﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace CLEXA.SurfaceClient
{
    public static class Helper
    {
        public static string GetServerNameFromConnectionString(string connectionString)
        {
            Match match = Regex.Match(connectionString, "Data Source=.*?;");
            string server = match.Value.Substring("Data Source=".Length, match.Value.Length - "Data Source=;".Length);
            return server;
        }

        public static string GetDatabaseNameFromConnectionString(string connectionString)
        {
            Match match = Regex.Match(connectionString, "Initial Catalog=.*?;");
            string server = match.Value.Substring("Initial Catalog=".Length, match.Value.Length - "Initial Catalog=;".Length);
            return server;
        }
    }
}
